package com.wlyy.his.service.registration;

import com.wlyy.his.entity.registration.HisDept;
import com.wlyy.his.entity.registration.HisDoctorSchedule;
import com.wlyy.his.ze.api.ZeGuoNeiApiService;
import com.wlyy.his.ze.bean.request.GUAHAOKSXX_IN_request;
import com.wlyy.his.ze.bean.request.GUAHAOYY_IN_request;
import com.wlyy.his.ze.bean.request.YIYUANPBXX_IN_request;
import com.wlyy.his.ze.bean.response.GUAHAOKSXX_OUT;
import com.wlyy.his.ze.bean.response.GUAHAOYY_OUT;
import com.wlyy.his.ze.bean.response.YIYUANPBXX_OUT;
import com.wlyy.his.ze.hepler.BeanCoverUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 10097
 * @date: 2021/9/1 09:48
 * @description:
 */
@Service
public class DemoRegistrationInitService {

    @Resource
    private IHisDeptService hisDeptService;

    @Resource
    private IHisDoctorScheduleService hisDoctorScheduleService;




    public void initDept(GUAHAOKSXX_IN_request request) {
        try {
            GUAHAOKSXX_OUT guahaoksxxOut = ZeGuoNeiApiService.guaHaoDept00531(request);
            if (!guahaoksxxOut.getKESHIXX().isEmpty()) {
                //保存
                List<HisDept> depts = BeanCoverUtil.coverBitch(guahaoksxxOut.getKESHIXX(), new HisDept());
                depts.forEach(b -> b.setHisCode(request.getBASEINFO().getFENYUANDM()));
                hisDeptService.saveBatch(depts);
            }
        } catch (Exception e) {

        }
    }

    public void initPaiBan(YIYUANPBXX_IN_request request) {
        YIYUANPBXX_OUT yiyuanpbxx = ZeGuoNeiApiService.yiyuanRoster05312(request);
        if (!yiyuanpbxx.getPAIBANMX().isEmpty()) {
            List<HisDoctorSchedule> doctorSchedules = BeanCoverUtil.coverBitch(yiyuanpbxx.getPAIBANMX(), new HisDoctorSchedule());
            doctorSchedules.forEach(d-> d.setHisCode(request.getBASEINFO().getFENYUANDM()));
            hisDoctorScheduleService.saveBatch(doctorSchedules);
        }
    }

}
